package com.example.isoftservice.controller;

import com.example.isoftservice.pojos.Dealer;
import com.example.isoftservice.service.DealerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * ClassNmae:DealerController
 * Descriptiopn:
 *
 * @Create 2023/10/26 11:16
 * @Author yidao
 */
@RestController
@CrossOrigin
@RequestMapping("/dealer")
public class DealerController {
    @Resource
    DealerService dealerService;

    //查询经销商信息
    @RequestMapping( value = "/searchDealerInfo",method = RequestMethod.POST)
    public Map<String,Object> searchDealerInfo(@RequestBody Dealer dealer){
        return dealerService.searchDealerInfo(dealer);
    }

    //查询经销商类别信息
    @RequestMapping("/searchDealerTypeInfo")
    public Map<String,Object> searchDealerTypeInfo(){
        return dealerService.searchDealerTypeInfo();
    }

    //查询机构大类信息
    @RequestMapping("/searchInstitutionBigInfo")
    public Map<String,Object> searchInstitutionBigInfo(){
        return dealerService.searchInstitutionBigInfo();
    }

    //根据大类显示小类信息
    @RequestMapping(value = "/searchInstitutionSmallByBig",method = RequestMethod.POST)
    public Map<String,Object> searchInstitutionSmallByBig(@RequestBody Dealer dealer){
        return dealerService.searchInstitutionSmallByBig(dealer);
    }


    //删除经销商信息
    @RequestMapping(value = "/removeDealerById",method = RequestMethod.POST)
    public Map<String,Object> removeDealerById(@RequestBody Dealer dealer){
        return dealerService.removeDealerById(dealer);
    }

    //添加经销商信息
    @RequestMapping(value = "/addDealerInfo",method = RequestMethod.POST)
    public Map<String,Object> addDealerInfo(@RequestBody Dealer dealer){
        return dealerService.addDealerInfo(dealer);
    }

    //更新经销商信息
    @RequestMapping(value = "/modifyDealerById",method = RequestMethod.POST)
    public Map<String,Object> modifyDealerById(@RequestBody Dealer dealer){
        System.out.println("dealer======="+dealer);
        return dealerService.modifyDealerById(dealer);
    }



}
